package a04toArraydemo4;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.function.IntFunction;

public class Test1 {
    public static void main(String[] args) {
        ArrayList<String> list1 = new ArrayList<>();
        Collections.addAll(list1, "ab-1", "a-2", "a-3");

        // list1.stream().forEach( s -> System.out.println(s));

//        long count = list1.stream().count();
//                System.out.println(count);

        // Object[] array = list1.stream().toArray();
        //System.out.println(Arrays.toString(array));

        String[] array = list1.stream().toArray(new IntFunction<String[]>() {
            @Override
            public String[] apply(int value) {
                return new String[value];
            }
        });

        // String[] array = list1.stream().toArray( value-> new String[value]);

        System.out.println(Arrays.toString(array));
    }
}
